package com.dfbz.service.impl;

import com.dfbz.dao.UserFocusDao;
import com.dfbz.entity.UserFocus;
import com.dfbz.service.UserFocusService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserFocusServiceImpl extends IServiceImpl<UserFocus> implements UserFocusService {

    @Autowired
    UserFocusDao userFocusDao;

    public Boolean addFollow(Integer loginUserId, Integer herId) {
        if (loginUserId!=null&&herId!=null){
            //先找我是否关注过他

            Integer ExistNum=userFocusDao.byFollowHer(loginUserId,herId);
            if (ExistNum<1){
                //添加关注
                userFocusDao.followHer(loginUserId, herId);
                return true;
            }else {
                //取消关注
                userFocusDao.unfollowHer(loginUserId,herId);
                return false;
            }
        }
        return false;
    }

    @Override
    public List<Integer> isFollowHer(String myId) {
        List<Integer> followList=userFocusDao.isFollowHer(myId);

        return followList;
    }


}
